//
//  DYZPutCarsSourceController.m
//  发布车源
//
//  Created by xmy on 16/8/18.
//  Copyright © 2016年 xmy. All rights reserved.
//

#import "DYZPutCarsSourceController.h"
#import "UILabel+Addition.h"
static NSString *cellid = @"cellid";

@interface DYZPutCarsSourceController ()
@property(nonatomic,assign)CGFloat eightHeight;

@end

@implementation DYZPutCarsSourceController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    
    self.navigationItem.title = @"推荐车源";
    self.view.backgroundColor = [UIColor whiteColor];
    
    // 加载xib
    UINib* nib = [UINib nibWithNibName:@"DYZRecommendCell" bundle:nil];
    // 获取xib中的视图
    UIView* pictureView = [nib instantiateWithOwner:nil options:nil][0];
    
    CGFloat xibH = pictureView.bounds.size.height;
    self.eightHeight = xibH;
    
    [self.tableView registerNib:nib forCellReuseIdentifier:cellid];
}

//设置headerView
- (void)setupUI{
    
    UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 60)];
    headerView.backgroundColor = [UIColor redColor];
    
    UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"sx_qd"]];
    imageView.frame = headerView.bounds;
    [headerView addSubview:imageView];
    
    UILabel *label = [UILabel labelWithText:@"您的寻车信息已经发布成功,经过系统智能匹配,和您的需求最相似的车源信息是:" andTextColor:[UIColor whiteColor] andFontSize:12];
    label.numberOfLines = 0;
    [headerView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(headerView).offset(10);
        make.right.equalTo(headerView).offset(-10);
        make.height.equalTo(headerView);
    }];
    
    self.tableView.tableHeaderView = headerView;
    
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 3;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid forIndexPath:indexPath];
    
    return cell;
}
//cell的高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;{
    
    return self.eightHeight;
        
}
//cell的点击事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //      取消cell的选中状态
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}
@end
